package com.aeye.mbr.upms.rpc.service.impl;

import com.aeye.mbr.cache.CacheService;
import com.aeye.mbr.upms.common.constant.UpmsCacheConstants;
import com.aeye.mbr.upms.dao.model.UpmsParam;
import com.aeye.mbr.upms.rpc.api.UpmsParamService;
import org.springframework.beans.factory.annotation.Autowired;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2018/3/14.
 */
public class UpmsParamCacheServiceImpl implements CacheService {

    @Autowired
    private UpmsParamService upmsParamService;

    @Override
    public String getCacheName() {
        return UpmsCacheConstants.UPMS_PARAM_CACHE;
    }

    @Override
    public Object getCacheObject() {
        List<UpmsParam> list = upmsParamService.getAllUpmsParams();
        Map<String,String> map = new HashMap<String,String>();
        for(UpmsParam p:list){
            map.put(p.getParamName(),p.getParamValue());
        }
        return map;
    }
}
